﻿@{
    ViewBag.Title = "news";
    Layout = "~/Views/Shared/_Layout_UserSite.cshtml";

    List<Pro_Building> info = ViewBag.lstNews != null ? (List<Pro_Building>)ViewBag.lstNews : new List<Pro_Building>();

    ViewBag.Title = info.FirstOrDefault().BuildingName;
}
@*slide show*@
<div class="tinnbcm ">
    <div id="items-tinnbcm" style="width: 345px; height: 325px;">
        @{
        
            List<Pro_Building> infoTop = info.Take(7).ToList();
            foreach (Pro_Building itemData in infoTop)
            {
                var imgurl = "../../Content/Image/admin/image_New.png";
                if (!string.IsNullOrEmpty(itemData.ImageFile))
                {
                    imgurl = "../Uploads/" + itemData.ImageFile;
                }
                
                var _description = itemData.Description.Length > 200 ? itemData.Description.Substring(0, 197) + "..." : itemData.Description;  
            
            <div class="item-tinnb ">
                <a class="link-tinnb" href="/tin-tuc/@itemData.Code">
                    <img class="img_mainNews" alt="@itemData.BuildingName" src="@imgurl" />
                </a>
                <div class="item_info">
                    <h1>
                        <a class="mainNewsTitle" title="@itemData.BuildingName" href="/tin-tuc/@itemData.Code">@(itemData.BuildingName.Length > 56 ? itemData.BuildingName.Substring(0, 53)+"..." : itemData.BuildingName)</a>
                    </h1>
                    <p>@Html.Raw(_description)</p>
                </div>
            </div>

            }
        }
    </div>
    <ul id="list_items">
        @{
            foreach (Pro_Building itemData in infoTop)
            {
                var imgurl_small = "../../Content/Image/admin/image_New.png";
                if (!string.IsNullOrEmpty(itemData.ImageFile))
                {
                    imgurl_small = "../Uploads/" + itemData.ImageFile;
                }
                int _titleLenght = itemData.BuildingName.Length;
                string newsTitle = itemData.BuildingName;
                if (_titleLenght > 45)
                {
                    newsTitle = newsTitle.Substring(0, 45) + "...";
                }
              
            <li class="itLi-tinnbcm Clearfix">
                <div class="div_image">
                    <a title="" href="/tin-tuc/@itemData.Code">
                        <img class="img_sub" alt=" @newsTitle " src="@imgurl_small" />
                    </a>
                </div>
                <div class="divTitle">
                    <a href="/tin-tuc/@itemData.Code">@newsTitle </a>
                </div>
            </li>
            
            }
        }
    </ul>
</div>
<div class="new_content">

@{
    List<Pro_Building> infoList = info.Skip(7).ToList();
    foreach (Pro_Building itemData in infoList)
    {
        var imgurl = "../../Content/Image/admin/image_New.png";
        if (!string.IsNullOrEmpty(itemData.ImageFile))
        {
            imgurl = "../Uploads/" + itemData.ImageFile;
        }
            
    <div class="div_row Clearfix">
        <div class="divTitleHome">
            <a href="/tin-tuc/@itemData.Code">@itemData.BuildingName </a>
        </div>
        <div class="divdesc">
            <div class="divdescHome">
                <a href="/tin-tuc/@itemData.Code">
                    <p>
                        <img alt="kimthanhhouse" src="@imgurl" class="imageNewHome" />
                        @Html.Raw(itemData.Description)
                    </p>
                </a>
            </div>
        </div>
    </div>
    }
    
    </div>
    
}
@section HeaderContent{
    @*cycle*@
    <script src="../../Scripts/Slide_Cycle/jquery.cycle.all.js" type="text/javascript"></script>
    <script src="../../Scripts/Slide_Cycle/urcCFC9.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            newsShow();
        });
        function newsShow() {
            $('#items-tinnbcm').cycle({
                fx: 'fade',
                speed: '400',
                timeout: 5000,
                pager: '#list_items',
                pagerEvent: 'mouseover',
                pauseOnPagerHover: true,
                pause: 1,
                allowPagerClickBubble: true,
                pagerAnchorBuilder: function (idx, slide) {
                    return '#list_items li:eq(' + (idx) + ')';
                }
            });
        }


    </script>
}
